<?php

namespace Biz;

use Base\BaseOrmModel;
use Base\Exception\NoRecordException;

class WinningLog extends \Base\BaseBiz
{
    /*查看本日是否已点击宝箱*/
    public function isClick($uid){
        try{
            // yes 0未开宝箱  1当天已开启宝箱
            $res = 0;
            $winning_log_list = new \Orm\WinningLog\WinningLogList();
            $winning_log_list["where"] = "user_id = ".$uid;
            $winning_log_list["order"] = "insert_time desc";
            $winning_log_list["limit"] =1;
            $winning_log_list->load();
            if (count($winning_log_list["lists"])>0) {
                $winning_log_res = $winning_log_list["lists"];
                $winning_log_res = reset($winning_log_res);
                $present_time = date("Y-m-d",time());
                $insert_time = date("Y-m-d",strtotime($winning_log_res["insert_time"]));
                if ($present_time == $insert_time) {
                    $res = 1;
                }
            }
            return $res;
        }catch (\Exception $e){
            throw new \Exception($e->getMessage());
        }
    }
}